.class public Lcom/netease/newsreader/util/ModelUtils;
.super Ljava/lang/Object;
.source "ModelUtils.java"


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 15
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static getValue(Ljava/util/Map;Ljava/lang/String;)Ljava/lang/Object;
    .locals 1
    .parameter
    .parameter "key"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/Object;",
            ">;",
            "Ljava/lang/String;",
            ")",
            "Ljava/lang/Object;"
        }
    .end annotation

    .prologue
    .line 123
    .local p0, map:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;"
    if-eqz p0, :cond_0

    invoke-static {p1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    if-eqz v0, :cond_1

    .line 124
    :cond_0
    const/4 v0, 0x0

    .line 126
    :goto_0
    return-object v0

    :cond_1
    invoke-interface {p0, p1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    goto :goto_0
.end method

.method public static json2Map(Lorg/json/JSONObject;)Ljava/util/Map;
    .locals 11
    .parameter "json"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lorg/json/JSONObject;",
            ")",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/Object;",
            ">;"
        }
    .end annotation

    .prologue
    .line 72
    new-instance v8, Ljava/util/HashMap;

    invoke-direct {v8}, Ljava/util/HashMap;-><init>()V

    .line 74
    .local v8, map:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;"
    if-eqz p0, :cond_1

    .line 75
    invoke-virtual {p0}, Lorg/json/JSONObject;->keys()Ljava/util/Iterator;

    move-result-object v4

    .line 77
    .local v4, iterator:Ljava/util/Iterator;,"Ljava/util/Iterator<Ljava/lang/String;>;"
    :cond_0
    :goto_0
    invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z

    move-result v10

    if-nez v10, :cond_2

    .line 112
    .end local v4           #iterator:Ljava/util/Iterator;,"Ljava/util/Iterator<Ljava/lang/String;>;"
    :cond_1
    return-object v8

    .line 79
    .restart local v4       #iterator:Ljava/util/Iterator;,"Ljava/util/Iterator<Ljava/lang/String;>;"
    :cond_2
    :try_start_0
    invoke-interface {v4}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Ljava/lang/String;

    .line 81
    .local v5, key:Ljava/lang/String;
    invoke-virtual {p0, v5}, Lorg/json/JSONObject;->isNull(Ljava/lang/String;)Z

    move-result v10

    if-nez v10, :cond_0

    .line 83
    invoke-virtual {p0, v5}, Lorg/json/JSONObject;->get(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v9

    .line 84
    .local v9, o:Ljava/lang/Object;
    if-eqz v9, :cond_0

    .line 88
    instance-of v10, v9, Lorg/json/JSONObject;

    if-eqz v10, :cond_3

    .line 89
    check-cast v9, Lorg/json/JSONObject;

    .end local v9           #o:Ljava/lang/Object;
    invoke-static {v9}, Lcom/netease/newsreader/util/ModelUtils;->json2Map(Lorg/json/JSONObject;)Ljava/util/Map;

    move-result-object v10

    invoke-interface {v8, v5, v10}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 105
    .end local v5           #key:Ljava/lang/String;
    :catch_0
    move-exception v2

    .line 106
    .local v2, e:Ljava/lang/Exception;
    invoke-virtual {v2}, Ljava/lang/Exception;->printStackTrace()V

    goto :goto_0

    .line 90
    .end local v2           #e:Ljava/lang/Exception;
    .restart local v5       #key:Ljava/lang/String;
    .restart local v9       #o:Ljava/lang/Object;
    :cond_3
    :try_start_1
    instance-of v10, v9, Lorg/json/JSONArray;

    if-eqz v10, :cond_5

    .line 91
    move-object v0, v9

    check-cast v0, Lorg/json/JSONArray;

    move-object v1, v0

    .line 92
    .local v1, array:Lorg/json/JSONArray;
    invoke-virtual {v1}, Lorg/json/JSONArray;->length()I

    move-result v6

    .line 93
    .local v6, length:I
    new-instance v7, Ljava/util/ArrayList;

    invoke-direct {v7}, Ljava/util/ArrayList;-><init>()V

    .line 94
    .local v7, list:Ljava/util/List;,"Ljava/util/List<Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;>;"
    const/4 v3, 0x0

    .local v3, i:I
    :goto_1
    if-lt v3, v6, :cond_4

    .line 98
    invoke-interface {v8, v5, v7}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    goto :goto_0

    .line 95
    :cond_4
    invoke-virtual {v1, v3}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v10

    invoke-static {v10}, Lcom/netease/newsreader/util/ModelUtils;->json2Map(Lorg/json/JSONObject;)Ljava/util/Map;

    move-result-object v10

    invoke-interface {v7, v10}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 94
    add-int/lit8 v3, v3, 0x1

    goto :goto_1

    .line 99
    .end local v1           #array:Lorg/json/JSONArray;
    .end local v3           #i:I
    .end local v6           #length:I
    .end local v7           #list:Ljava/util/List;,"Ljava/util/List<Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;>;"
    :cond_5
    instance-of v10, v9, Ljava/lang/String;

    if-eqz v10, :cond_6

    .line 100
    check-cast v9, Ljava/lang/String;

    .end local v9           #o:Ljava/lang/Object;
    invoke-static {v9}, Lcom/netease/newsreader/util/Tools;->htmlDecoder(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v10

    invoke-interface {v8, v5, v10}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    goto :goto_0

    .line 102
    .restart local v9       #o:Ljava/lang/Object;
    :cond_6
    invoke-interface {v8, v5, v9}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_0
.end method

.method public static map2Json(Ljava/util/Map;)Lorg/json/JSONObject;
    .locals 11
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/Object;",
            ">;)",
            "Lorg/json/JSONObject;"
        }
    .end annotation

    .prologue
    .line 24
    .local p0, map:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;"
    new-instance v5, Lorg/json/JSONObject;

    invoke-direct {v5}, Lorg/json/JSONObject;-><init>()V

    .line 25
    .local v5, json:Lorg/json/JSONObject;
    if-eqz p0, :cond_1

    .line 26
    invoke-interface {p0}, Ljava/util/Map;->keySet()Ljava/util/Set;

    move-result-object v10

    invoke-interface {v10}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v4

    .line 27
    .local v4, iterator:Ljava/util/Iterator;,"Ljava/util/Iterator<Ljava/lang/String;>;"
    :cond_0
    :goto_0
    invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z

    move-result v10

    if-nez v10, :cond_2

    .line 62
    .end local v4           #iterator:Ljava/util/Iterator;,"Ljava/util/Iterator<Ljava/lang/String;>;"
    :cond_1
    return-object v5

    .line 29
    .restart local v4       #iterator:Ljava/util/Iterator;,"Ljava/util/Iterator<Ljava/lang/String;>;"
    :cond_2
    :try_start_0
    invoke-interface {v4}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v6

    check-cast v6, Ljava/lang/String;

    .line 31
    .local v6, key:Ljava/lang/String;
    invoke-interface {p0, v6}, Ljava/util/Map;->containsKey(Ljava/lang/Object;)Z

    move-result v10

    if-eqz v10, :cond_0

    .line 33
    invoke-interface {p0, v6}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v9

    .line 34
    .local v9, o:Ljava/lang/Object;
    if-eqz v9, :cond_0

    .line 38
    instance-of v10, v9, Ljava/util/Map;

    if-eqz v10, :cond_3

    .line 39
    check-cast v9, Ljava/util/Map;

    .end local v9           #o:Ljava/lang/Object;
    invoke-static {v9}, Lcom/netease/newsreader/util/ModelUtils;->map2Json(Ljava/util/Map;)Lorg/json/JSONObject;

    move-result-object v10

    invoke-virtual {v5, v6, v10}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 56
    .end local v6           #key:Ljava/lang/String;
    :catch_0
    move-exception v2

    .line 57
    .local v2, e:Ljava/lang/Exception;
    invoke-virtual {v2}, Ljava/lang/Exception;->printStackTrace()V

    goto :goto_0

    .line 40
    .end local v2           #e:Ljava/lang/Exception;
    .restart local v6       #key:Ljava/lang/String;
    .restart local v9       #o:Ljava/lang/Object;
    :cond_3
    :try_start_1
    instance-of v10, v9, Ljava/util/List;

    if-eqz v10, :cond_5

    .line 41
    move-object v0, v9

    check-cast v0, Ljava/util/List;

    move-object v8, v0

    .line 42
    .local v8, list:Ljava/util/List;
    invoke-interface {v8}, Ljava/util/List;->size()I

    move-result v7

    .line 43
    .local v7, length:I
    new-instance v1, Lorg/json/JSONArray;

    invoke-direct {v1}, Lorg/json/JSONArray;-><init>()V

    .line 45
    .local v1, array:Lorg/json/JSONArray;
    const/4 v3, 0x0

    .local v3, i:I
    :goto_1
    if-lt v3, v7, :cond_4

    .line 49
    invoke-virtual {v5, v6, v1}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    goto :goto_0

    .line 46
    :cond_4
    move-object v0, v9

    check-cast v0, Ljava/util/Map;

    move-object v10, v0

    invoke-static {v10}, Lcom/netease/newsreader/util/ModelUtils;->map2Json(Ljava/util/Map;)Lorg/json/JSONObject;

    move-result-object v10

    invoke-virtual {v1, v10}, Lorg/json/JSONArray;->put(Ljava/lang/Object;)Lorg/json/JSONArray;

    .line 45
    add-int/lit8 v3, v3, 0x1

    goto :goto_1

    .line 50
    .end local v1           #array:Lorg/json/JSONArray;
    .end local v3           #i:I
    .end local v7           #length:I
    .end local v8           #list:Ljava/util/List;
    :cond_5
    instance-of v10, v9, Ljava/lang/String;

    if-eqz v10, :cond_6

    .line 51
    check-cast v9, Ljava/lang/String;

    .end local v9           #o:Ljava/lang/Object;
    invoke-static {v9}, Lcom/netease/newsreader/util/Tools;->htmlDecoder(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v5, v6, v10}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    goto :goto_0

    .line 53
    .restart local v9       #o:Ljava/lang/Object;
    :cond_6
    invoke-virtual {v5, v6, v9}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_0
.end method
